package com.flying.invest.assets.model;

import java.util.Date;

import com.flying.common.util.Codes;
import com.flying.framework.annotation.Param;
import com.flying.framework.annotation.ServiceField;
import com.flying.framework.annotation.ServiceFieldParam;
import com.flying.framework.data.Data;
import com.flying.framework.data.DataSerializable;
import com.flying.framework.metadata.Meta;

@SuppressWarnings("serial")
@Meta(id="i_assets_price_spider",title="价格爬虫", table="i_assets_price_spider", primaryKeys={"spider_id"})
public class AssetsPriceSpider extends Data implements DataSerializable {
	public final static String ENTITY_NAME = "i_assets_price_spider";
	
	public final static String SPIDER_ID = "spider_id";
	public final static String USER_ID = "user_id";
	public final static String ASSETS_ID = "assets_id";
	public final static String URL = "url";
	public final static String PARAMS = "params";
	public final static String MODULE = "module";
	public final static String SERVICE = "service";
	public final static String INTERVALS = "intervals";
	public final static String REMARKS = "remarks";
	public final static String CREATE_TIME = "create_time";
	public final static String NEXT_TIME = "next_time";
	
	
	@Param(value=SPIDER_ID,   required=true,   maxlength=0,	desc="SPIDER ID" , generator=Codes.AUTO_INCREMENT)
	private Long spiderId;
	
	@Param(value=USER_ID,   required=true,   maxlength=0,	desc="用户ID" )
	private Long userId;
	
	@Param(value=ASSETS_ID,   required=true,   maxlength=0,	desc="投资品种ID" )
	private Long assetsId;
	
	@Param(value=URL,   required=false,   maxlength=200,	desc="价格页面" )
	private String url;
	
	@Param(value=PARAMS,   required=false,   maxlength=400,	desc="价格页面参数" )
	private String params;
	
	@Param(value=MODULE,   required=false,   maxlength=20,	desc="解析模块" )
	private String module;
	
	@Param(value=SERVICE,   required=false,   maxlength=60,	desc="解析服务" )
	private String service;
	
	@Param(value=INTERVALS,   required=false,   maxlength=0,	desc="时间间隔" )
	private Long intervals;
	
	@Param(value=REMARKS,   required=false,   maxlength=400,	desc="说明" )
	private String remarks;
	
	@Param(value=CREATE_TIME,   required=false,   maxlength=0,	desc="创建时间" )
	private Date createTime;
	
	@Param(value=NEXT_TIME,   required=false,   maxlength=0,	desc="下次执行时间" )
	private Date nextTime;
	//
	@ServiceField(serviceId="AssetsService:findById", params={@ServiceFieldParam(param=Assets.ASSETS_ID, value="$"+ASSETS_ID)})
	@Param(value="assets",   required=false,	desc="资产", ignored=true)
	private Assets assets;
	
	
	public Long getSpiderId() {
		return this.spiderId;
	}
	
	public void setSpiderId(Long spiderId) {
		this.spiderId = spiderId;
	}
	
	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Long getAssetsId() {
		return this.assetsId;
	}
	
	public void setAssetsId(Long assetsId) {
		this.assetsId = assetsId;
	}
	
	public String getUrl() {
		return this.url;
	}
	
	public void setUrl(String url) {
		this.url = url;
	}
	
	public String getParams() {
		return this.params;
	}
	
	public void setParams(String params) {
		this.params = params;
	}
	
	public String getModule() {
		return this.module;
	}
	
	public void setModule(String module) {
		this.module = module;
	}
	
	public String getService() {
		return this.service;
	}
	
	public void setService(String service) {
		this.service = service;
	}
	
	public Long getIntervals() {
		return this.intervals;
	}
	
	public void setIntervals(Long intervals) {
		this.intervals = intervals;
	}
	
	public String getRemarks() {
		return this.remarks;
	}
	
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	
	public Date getCreateTime() {
		return this.createTime;
	}
	
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	public Date getNextTime() {
		return this.nextTime;
	}
	
	public void setNextTime(Date nextTime) {
		this.nextTime = nextTime;
	}

	//
	public Assets getAssets() {
		return assets;
	}

	public String getAssetsName() {
		Assets t = this.getAssets();
		if(t != null) {
			return t.getName();
		} else {
			return null;
		}
	}

}